package LeetCode.month02.day41;

import java.util.Arrays;

public class No242 {
    public static void main(String[] args) {
        System.out.println(isAnagram("rat","car"));
    }
    public static boolean isAnagram(String s, String t) {
        int n = s.length();
        int m = t.length();
        if(n!=m) return false;
        int[] arr =new int[26];
        for (int i = 0; i < n; i++) {
            arr[s.charAt(i)-'a']++;
        }
        for (int i = 0; i < m; i++) {
            int index = t.charAt(i)-'a';
            if(--arr[index]<0) return false;
        }
        return true;
    }
}
